﻿using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Mock1G3.BussinessLogic;
using Mock1G3.BaseEntities;
using System.Data;
using Mock1G3.DataAccess;

namespace Test_Mock1G3.TransferCash
{
    /// <summary>
    /// Summary description for AccountTransfer
    /// </summary>
    [TestClass]
    public class AccountTransfer
    {
        public AccountTransfer()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        private TestContext testContextInstance;
        AccountTransferLogic accountTransfer = new AccountTransferLogic();

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        //
        // You can use the following additional attributes as you write your tests:
        //
        // Use ClassInitialize to run code before running the first test in the class
        // [ClassInitialize()]
        // public static void MyClassInitialize(TestContext testContext) { }
        //
        // Use ClassCleanup to run code after all tests in a class have run
        // [ClassCleanup()]
        // public static void MyClassCleanup() { }
        //
        // Use TestInitialize to run code before running each test 
        // [TestInitialize()]
        // public void MyTestInitialize() { }
        //
        // Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup() { }
        //
        #endregion

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest()
        {            
            string str = "12345678901234";
            bool expect = true;
            bool actual = accountTransfer.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest1()
        {
            AccountTransferLogic accountTransfer = new AccountTransferLogic();
            string str = "1234a89b01x23y";
            bool expect = false;
            bool actual = accountTransfer.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest2()
        {
            string str = "";
            bool expect = false;
            bool actual = accountTransfer.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest3()
        {
            string str = "#456732350";
            bool expect = false;
            bool actual = accountTransfer.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for IsNumber check
        /// </summary>
        [TestMethod]
        public void IsNumberTest4()
        {
            string str = @"#@!~`$%^&*()+=-_{}?/\|";
            bool expect = false;
            bool actual = accountTransfer.IsNumber(str);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest()
        {
            Account account = new Account();
            account.AccountNoRev = "";
            bool expect = false ;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest1()
        {
            Account account = new Account();
            account.AccountNoRev = "98456a4b88h";
            bool expect = false;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// Param AccountNoRev value is not exist
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest2()
        {
            Account account = new Account();
            account.AccountNoRev = "9867543";
            bool expect = false;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// Param AccountNoRev value is too much, greater 50 character
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest3()
        {
            Account account = new Account();
            account.AccountNoRev = "123456789012345678901234567890123456789012345678901";
            bool expect = false;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// Param AccountNoRev value , 50 character, exist on database
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest4()
        {
            Account account = new Account();
            account.AccountNoRev = "12345678901234567890123456789012345678901234567890";
            bool expect = true;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// Param AccountNoRev value has 49 character, exist on database
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest5()
        {
            Account account = new Account();
            account.AccountNoRev = "1234567890123456789012345678901234567890123456789";
            bool expect = true;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// Param AccountNoRev value not exist on database
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest6()
        {
            Account account = new Account();
            account.AccountNoRev = "98745754648";
            bool expect = false;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for CheckAccountReceive
        /// Param AccountNoRev value not exist on database
        /// </summary>
        [TestMethod]
        public void CheckAccountReceiveTest7()
        {
            Account account = new Account();
            account.AccountNoRev = "9874575464";
            bool expect = true;
            bool actual = accountTransfer.CheckAccountReceive(account);
            Assert.AreEqual(expect, actual);
        }

        /// <summary>
        /// A test for GetAccountReceive, exist AccountNoRev on DB
        /// </summary>
        [TestMethod]
        public void GetAccountReceiveTest()
        {
            Account account = new Account();
            account.AccountNoRev = "9874575464";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSelectByNo]", "@AccountNo", account.AccountNoRev);
            DataTable actual = accountTransfer.GetAccountReceive(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountReceive, not exist AccountNoRev on DB
        /// </summary>
        [TestMethod]
        public void GetAccountReceiveTest1()
        {
            Account account = new Account();
            account.AccountNoRev = "456798324534512";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSelectByNo]", "@AccountNo", account.AccountNoRev);
            DataTable actual = accountTransfer.GetAccountReceive(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountReceive, with 50 character exist AccountNoRev on DB
        /// </summary>
        [TestMethod]
        public void GetAccountReceiveTest2()
        {
            Account account = new Account();
            account.AccountNoRev = "12345678901234567890123456789012345678901234567890";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSelectByNo]", "@AccountNo", account.AccountNoRev);
            DataTable actual = accountTransfer.GetAccountReceive(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountReceive, with 60 character, too much
        /// </summary>
        [TestMethod]
        public void GetAccountReceiveTest3()
        {
            Account account = new Account();
            account.AccountNoRev = "123456789012345678901234567890123456789012345678901234567890";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSelectByNo]", "@AccountNo", account.AccountNoRev);
            DataTable actual = accountTransfer.GetAccountReceive(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountSend function
        /// </summary>
        [TestMethod]
        public void GetAccountSendTest()
        {
            Account account = new Account();
            account.AccountNo = "9874575464";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSendSelectByNo]", "@AccountNo", account.AccountNo);
            DataTable actual = accountTransfer.GetAccountSend(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountSend function, not exist on DB
        /// </summary>
        [TestMethod]
        public void GetAccountSendTest1()
        {
            Account account = new Account();
            account.AccountNo = "456798324534512";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSendSelectByNo]", "@AccountNo", account.AccountNo);
            DataTable actual = accountTransfer.GetAccountSend(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountSend function, with 50 character exist AccountNoRev on DB
        /// </summary>
        [TestMethod]
        public void GetAccountSendTest2()
        {
            Account account = new Account();
            account.AccountNo = "12345678901234567890123456789012345678901234567890";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSendSelectByNo]", "@AccountNo", account.AccountNo);
            DataTable actual = accountTransfer.GetAccountSend(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }

        /// <summary>
        /// A test for GetAccountReceive, with 60 character, too much
        /// </summary>
        [TestMethod]
        public void GetAccountSendTest3()
        {
            Account account = new Account();
            account.AccountNo = "123456789012345678901234567890123456789012345678901234567890";
            DataTable expect = DataAccess.ExeStoredWithParamToDataTable("dbo.[usp_AccountSendSelectByNo]", "@AccountNo", account.AccountNo);
            DataTable actual = accountTransfer.GetAccountSend(account);
            Assert.IsTrue(Utility.CompareDataTable(expect, actual));
        }
    }
}
